public class Solution334 {
    public boolean increasingTriplet(int[] nums) {
        int l=1;
        int[] d=new int[5];
        d[1]=nums[0];
        int n=nums.length;
        for (int i=1;i<n;i++){
            if (nums[i]>d[l]){
                l++;
                if (l==3){
                    return true;
                }
                d[l]=nums[i];
            }else{
                if (nums[i]<d[1]){
                    d[1]=nums[i];
                }else if (nums[i]>d[1] && nums[i]<d[2]){
                    d[2]=nums[i];
                }
            }
        }
        return false;
    }

    public static void main(String[] args) {
        System.out.println(new Solution334().increasingTriplet(new int[]{1,2,3,4,5}));
    }
}
